package com.six.flower.mapper

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper
import com.baomidou.mybatisplus.core.mapper.BaseMapper
import com.six.library.model.Flowers
import org.apache.commons.lang.StringUtils
import org.apache.ibatis.annotations.Mapper
import org.apache.ibatis.annotations.Select


/*-*- coding:utf-8 -*-
 * @Author  : debi
 * @Time    : 10/22/22
 * @Software: IntelliJ IDEA
 */
@Mapper
interface FlowersMapper : BaseMapper<Flowers> {
    @Select("SELECT * FROM FlowerManage.flowers ")
    fun findAll(): MutableList<Flowers>
}

fun Flowers.Companion.nameNotEmptyLike(flowerName: String): QueryWrapper<Flowers> = QueryWrapper<Flowers>().apply {
    this.like(StringUtils.isNotEmpty(flowerName), "name", flowerName)
}
fun Flowers.Companion.updateWrapper(flower: Flowers): UpdateWrapper<Flowers> = UpdateWrapper<Flowers>().apply {
    this.set(!StringUtils.isEmpty(flower.name),"name", flower.name)
    this.set(!StringUtils.isEmpty(flower.imgUrl),"imgUrl", flower.imgUrl)
    this.set(!StringUtils.isEmpty(flower.fLanguage),"fLanguage", flower.fLanguage)
}
